package com.zkgengkun.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

/**
 * @author gengshikun
 * @date 2016/11/28
 */
@Configuration
@ImportResource("classpath:spring/application-data.xml")
public class DataSourceConfig {
    /**
     * Logger for this class
     */
    private static final Logger logger = LoggerFactory.getLogger(DataSourceConfig.class);

//    @Bean(name = "primaryDataSource")
//    @Primary
//    @ConfigurationProperties(prefix = "datasource.primary")
//    public DataSource primaryDataSource() {
//        logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>primary datasource init..............");
//        DataSource ds = DataSourceBuilder.create().build();
//        return ds;
//    }
//
//    /**
//     * 只读库  生产环境可以使用dns在多个读库中负载均衡
//     */
//    @Bean(name = "readDataSource")
//    @ConfigurationProperties(prefix = "datasource.read")
//    public DataSource readDataSource() {
//        logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>read datasource init.............");
//        return DataSourceBuilder.create().build();
//    }
//
//    @Bean(name = "primaryJdbcTemplate")
//    public JdbcTemplate primaryJdbcTemplate(@Qualifier("primaryDataSource") DataSource dataSource) {
//        return new JdbcTemplate(dataSource);
//    }
//
//    @Bean(name = "readJdbcTemplate")
//    public JdbcTemplate readJdbcTemplate(@Qualifier("readDataSource") DataSource dataSource) {
//        return new JdbcTemplate(dataSource);
//    }

}
